﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace UI.View.Repairs
{
    /// <summary>
    /// List.xaml 的交互逻辑
    /// </summary>
    public partial class YiBan : Page
    {


        ViewModel.RepairViewModel vm;
        
        public YiBan()
        {
            InitializeComponent();
            vm = DataContext as ViewModel.RepairViewModel;

            vm.GetYiBan();
        }

        private async void Btn_Query_Click(object sender, RoutedEventArgs e)
        {
            vm.ListRepairs = await vm.Query(txt_RepairID.Text,  dtp_StartTime.SelectedDateTime,  dtp_EndTime.SelectedDateTime,"已维修");
        }

        private void Btn_CreateRepair_Click(object sender, RoutedEventArgs e)
        {
            //MainWindow.GetMain().Frm.Navigate(new View.Repairs.New());
           // HandyControl.Controls.Dialog.Show(View.Repairs.a);

            if(vm.CurrRepair==null)
            {
                HandyControl.Controls.Growl.WarningGlobal("请选择维修单！");
                return;
            }

            vm.CurrRepair.State = "已维修";
            vm.Save(vm.CurrRepair);
        }
    }
}
